//
//  APITargetType.swift
//  DaFit
//
//  Created by 尹琼 on 2022/11/25.
//  Copyright © 2022 sylar. All rights reserved.
//

import UIKit
import Moya

public protocol APITargetType: TargetType {
    
    /// 是否验证用户身份
    var validUser: Bool { get }
    
    /// 超时时间
    var timeoutInterval: Double { get }
    
    /// 是否走测试数据，默认 .never
    var stubBehavior: Moya.StubBehavior { get }
    
    
}

public extension APITargetType {
    
     var baseURL: URL {
         
         return BaseURL.common.url
    }
    
    var validUser: Bool {
        
        return false
    }
    
    var timeoutInterval: Double {
        
        return 10
    }
    
    
     var stubBehavior: Moya.StubBehavior {
        
        return .never
    }
    
    var headers: [String : String]? {
        
        guard let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String else {
            return nil
        }
        
        return [
            "User-Agent": "MoYoung/\(appVersion) (iPhone; iOS 9.3.4; Scale/2.00)",
        ]
        
    }
}
    

